const {
    arrayToMap
} = rx
const app = new BasicTableVue({
    data() {
        return {
            api: tlogOperationApi,
            columns: [
                new TableColumn({width: 30, type: 'selection'}),
                new TableColumn({prop: 'operObject', title: '对象'}),
                new TableColumn({
                    prop: 'operType', title: '类型',
                    formatter: fieldFormatter.facade(fieldFormatter.tlogSecurity.operTypeMap),
                }),
                new TableColumn({prop: 'loginName', title: '用户名'}),
                new TableColumn({prop: 'sourceIp', title: '来源IP'}),
                new TableColumn({prop: 'operTime', title: '时间', formatter: TableColumn.datetimeFormat}),
                new TableColumn({prop: 'message', title: '消息'}),
                new TableColumn({prop: 'operating', title: '查看', customComponent: true}),

            ],
            sysRoleList: [],
            sysRoleMap: new Map(),
        }
    },
    methods: {
        createForm() {
            return new TlogOperationVo()
        },
        async init() {
            this.sysRoleListInit()
        },
        viewInfo(row) {
            const pagestartIndex = (this.page.current - 1) * this.page.size
            const endIndex = this.page.total - 1
            forward('/security-log/see/admin_security_auditlogdetail', {
                id: row.id,
                page: this.page,
                entity: this.form,
                pagestartIndex: pagestartIndex,
                endIndex: endIndex,
            })

        },
        async sysRoleListInit() {
            this.sysRoleList = await sysRoleApi.listForAll()
            this.sysRoleMap = arrayToMap(this.sysRoleList, ({id}) => id, ({name}) => name)
        },
    },
    computed: {
        fieldFormatter() {
            return fieldFormatter
        },
    },

})
